import endians

proc toBigEndian*[T](value: T): T =
  var value = value
  when sizeof(T) == 1:
    result = value
  when sizeof(T) == 2:
    bigEndian16(result.addr, value.addr)
  when sizeof(T) == 4:
    bigEndian32(result.addr, value.addr)
  when sizeof(T) == 8:
    bigEndian64(result.addr, value.addr)
